<?php

/**
 * Rel form base class.
 *
 * @method Rel getObject() Returns the current form's model object
 *
 * @package    LIAnnot
 * @subpackage form
 * @author     Cedric Richier
 * @version    SVN: $Id: sfDoctrineFormGeneratedTemplate.php 29553 2010-05-20 14:33:00Z Kris.Wallsmith $
 */
abstract class BaseRelForm extends BaseFormDoctrine
{
  public function setup()
  {
    $this->setWidgets(array(
      'id'        => new sfWidgetFormInputHidden(),
      'id_struct' => new sfWidgetFormDoctrineChoice(array('model' => $this->getRelatedModelName('Struct'), 'add_empty' => false)),
      'att_id'    => new sfWidgetFormInputText(),
      'href'      => new sfWidgetFormInputText(),
      'type'      => new sfWidgetFormInputText(),
    ));

    $this->setValidators(array(
      'id'        => new sfValidatorChoice(array('choices' => array($this->getObject()->get('id')), 'empty_value' => $this->getObject()->get('id'), 'required' => false)),
      'id_struct' => new sfValidatorDoctrineChoice(array('model' => $this->getRelatedModelName('Struct'))),
      'att_id'    => new sfValidatorString(array('max_length' => 40, 'required' => false)),
      'href'      => new sfValidatorString(array('max_length' => 80)),
      'type'      => new sfValidatorString(array('max_length' => 40, 'required' => false)),
    ));

    $this->widgetSchema->setNameFormat('rel[%s]');

    $this->errorSchema = new sfValidatorErrorSchema($this->validatorSchema);

    $this->setupInheritance();

    parent::setup();
  }

  public function getModelName()
  {
    return 'Rel';
  }

}
